var t = getApp();

Page({
    data: {
        storeId: 0,
        isLoadMore: !0,
        page: 1,
        totalPage: 0,
        incomeList: [],
        userInfo: {},
        finishMoney: 0,
        waitMoney: 0,
        sumMoney: 0,
        incomeTabs: [ {
            name: "全部",
            status: 0
        }, {
            name: "已结算",
            status: 2
        }, {
            name: "未结算",
            status: 1
        } ],
        incomeStatus: 0
    },
    onLoad: function(t) {
        var a;
        "" !== (null !== (a = t.storeId) && void 0 !== a ? a : "") && (this.data.storeId = parseInt(t.storeId)), 
        this.incomeList();
    },
    incomeList: function() {
        var a = this, o = t.getNetAddresss("plugin.coupon-store.frontend.store-manage.moneyList"), e = {
            cstore_id: this.data.storeId,
            status: this.data.incomeStatus
        };
        t._postNetWork({
            url: o,
            data: e,
            success: function(t) {
                var o = t.data;
                wx.hideLoading(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh(), 1 == o.result ? (console.log(o), 
                a.data.isLoadMore = !0, a.data.totalPage = o.data.last_page, a.data.totalPage || (a.data.totalPage = 0), 
                a.setData({
                    incomeList: o.data.data,
                    userInfo: o.data.member,
                    finishMoney: o.data.finish_money,
                    waitMoney: o.data.wait_money,
                    sumMoney: o.data.sum_money
                })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onIncomeChange: function(t) {
        this.setData({
            incomeStatus: t.detail.name,
            page: 1
        }), this.incomeList();
    },
    getMoreData: function() {
        var a = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.totalPage)) {
            this.data.page = this.data.page + 1;
            var o = t.getNetAddresss("plugin.coupon-store.frontend.store-manage.moneyList"), e = {
                cstore_id: this.data.storeId,
                status: this.data.incomeStatus
            };
            t._getNetWork({
                url: o,
                data: e,
                success: function(t) {
                    var o = t.data, e = o.data.data;
                    1 == o.result ? (a.data.isLoadMore = !0, a.setData({
                        incomeList: a.data.incomeList.concat(e)
                    })) : (a.data.page = a.data.page - 1, a.isLoadMore = !1, wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 1500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        wx.showNavigationBarLoading(), wx.showLoading({
            title: "刷新中..."
        }), this.setData({
            page: 1,
            incomeStatus: 0
        }), this.incomeList();
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多了");
    },
    onShareAppMessage: function() {}
});